package com.yqs.maven_jdbc.utils;

import java.sql.*;

/**
 * @author Ye QS
 * @version 0.1
 * @className JDBCUtils
 * @description
 * @date 2024/7/23 15:17
 * @since jdk11
 */
public class JDBCUtils {
    public static Connection getConn() {
        Connection conn = null;

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/atguigu", "root", "Yqs@030621");
            return conn;
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
    }
        public static void closeAll(Connection conn, Statement st, ResultSet rs) {
            try {
                if (rs != null) {
                    rs.close();
                }
                if (st != null) {
                    st.close();
                }
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }


        }
    }